//package com.ruoyi.web.core.config;
//
//import com.ruoyi.weixin.entity.FileAndStringMessage;
//import org.springframework.amqp.rabbit.annotation.RabbitListener;
//import org.springframework.stereotype.Component;
//
//import javax.imageio.ImageIO;
//import java.awt.image.BufferedImage;
//import java.io.*;
//import java.nio.file.Files;
//import java.nio.file.Path;
//import java.nio.file.Paths;
//import java.nio.file.StandardOpenOption;
//
//@Component
//public class SpringRabbitLeistener {
//
//    @RabbitListener(queues = "picture.upoad")
//    public void listenSimpleQueueMessage(FileAndStringMessage fileAndStringMessage)throws Exception {
//        String fileName = fileAndStringMessage.getFileName();
//        byte[] bytes = fileAndStringMessage.getFileBytes();
//        String path = fileAndStringMessage.getMessage();
//
//        ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
//        BufferedImage bi1 = ImageIO.read(bais);
//        try {
//            File w2 = new File("/home/ruoyi/uploadPath/"+path);//可以是jpg,png,gif格式
//            if (!w2.exists()){
//                w2.mkdirs();
//            }
//            File w=new File("/home/ruoyi/uploadPath/"+path+"/"+fileName+".jpg");//可以是jpg,png,gif格式
//            ImageIO.write(bi1, "jpg", w);//不管输出什么格式图片，此处不需改动
//        } catch (IOException e) {
//            e.printStackTrace();
//        }finally{
//            bais.close();
//        }
//
//    }
//}